package com.example.gcr.controller;


import com.example.gcr.dao.UserMapper;
import com.example.gcr.tool.ResBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class DateController {

    @Resource
    UserMapper userMapper;


    @RequestMapping("/")
    @ResponseBody
    public String wel() {
        return "基础sb加mybatis";
    }

    @RequestMapping("/find")
    @ResponseBody
    public Object findUser() {
        List ls = userMapper.findAll();
        ResBean rb = new ResBean("0", "成功", ls);
        return rb;
    }

    @RequestMapping("/dele")
    @ResponseBody
    public Object dele(Integer id) {
        int i = userMapper.deleteByPrimaryKey(id);
        ResBean rb = null;
        if (i == 1) {
            rb = new ResBean("0", "成功");
        }
        return rb;
    }
}
